﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using Model;
namespace DAL
{
    public class h_orderDal
    {
        public static int Addord(h_order ord)
        {
            string sql = "insert into h_order(o_ordersn,o_shop_name,o_residential,o_delivery_fee,o_tel,o_pickup_address,o_delivery_time_start,o_delivery_time_end,o_delivery_address,o_create_time) values(@o_ordersn,@o_shop_name,@o_residential,@o_delivery_fee,@o_tel,@o_pickup_address,@o_delivery_time_start,@o_delivery_time_end,@o_delivery_address,@o_create_time)";
            MySqlParameter[] values = new MySqlParameter[10];
            values[0] = new MySqlParameter("o_ordersn", ord.o_ordersn);
            values[1] = new MySqlParameter("o_residential", ord.o_residential);
            values[2] = new MySqlParameter("o_delivery_fee", ord.o_delivery_fee);
            values[3] = new MySqlParameter("o_pickup_address", ord.o_pickup_address);
            values[4] = new MySqlParameter("o_delivery_time_start", ord.o_delivery_time_start);
            values[5] = new MySqlParameter("o_delivery_time_end", ord.o_delivery_time_end);
            values[6] = new MySqlParameter("o_delivery_address", ord.o_delivery_address);
            values[7] = new MySqlParameter("o_create_time", ord.o_create_time);
            values[8] = new MySqlParameter("o_shop_name", ord.o_shop_name);
            values[9] = new MySqlParameter("o_tel", ord.o_tel);
            return HKHelper.ExcutUpdate(sql, values);
        }
        /// <summary>
        /// 骑手商品
        /// </summary>
        /// <param name="ord"></param>
        /// <returns></returns>
        public static int Addgoods(h_order_goods ord)
        {
            string sql = "insert into h_order_goods(og_oordersn,og_ordersn,og_delivery_fee,og_goodsinfo,og_tel,og_nickname,og_delivery_address,og_paysn,og_openid) values(@og_oordersn,@og_ordersn,@og_delivery_fee,@og_goodsinfo,@og_tel,@og_nickname,@og_delivery_address,@og_paysn,@og_openid)";
            MySqlParameter[] values = new MySqlParameter[9];
            values[0] = new MySqlParameter("og_oordersn", ord.og_oordersn);
            values[1] = new MySqlParameter("og_ordersn", ord.og_ordersn);
            values[2] = new MySqlParameter("og_goodsinfo", ord.og_goodsinfo);
            values[3] = new MySqlParameter("og_tel", ord.og_tel);
            values[4] = new MySqlParameter("og_nickname", ord.og_nickname);
            values[5] = new MySqlParameter("og_delivery_address", ord.og_delivery_address);
            values[6] = new MySqlParameter("og_delivery_fee", ord.og_delivery_fee);
            values[7] = new MySqlParameter("og_paysn", ord.og_paysn);
            values[8] = new MySqlParameter("og_openid", ord.og_openid);
            return HKHelper.ExcutUpdate(sql, values);
        }
    }
}
